package ac.github.os.internal.core.holder.entity

import ac.github.os.internal.core.holder.BlockCompatible
import ac.github.os.internal.core.holder.EventHolder
import org.bukkit.block.Block
import org.bukkit.event.player.PlayerInteractEvent

class InteractHolder(override val event: PlayerInteractEvent) : EventHolder<PlayerInteractEvent>, BlockCompatible {

    override val namespace: String
        get() = "player interact"

    override fun variable(string: String): String? {
        return when (string) {
            "action" -> event.action.name
            "hand" -> event.hand?.name
            "item:name" -> event.item?.itemMeta?.displayName
            "item:id" -> event.item?.type?.name ?: "ARI"
            else -> ""
        }
    }

    override fun getBlock(): Block? {
        return event.clickedBlock
    }

}